#pragma once

#include "Win32Base.h"

class CTabWindow : public CWindowBase
{
	struct sTab
	{
		RECT		m_rcTab;
		std::string m_szName;
		COLORREF	m_cText;
		HWND		m_hWnd;
	};

	typedef std::list<sTab*>	TAB_LIST;

public:
	CTabWindow();
	virtual ~CTabWindow();

	bool Create(HINSTANCE hInstance,HWND hParentWnd);
	void Release();

	bool	AddTab(LPCSTR name,HWND hWnd,COLORREF cText = RGB( 0, 0, 0));

	int		GetTabCount(){return m_TabList.size();}

	void	SetTabColor(COLORREF cTabColor,COLORREF cHighlightedTabColor);

protected:
	TAB_LIST	m_TabList;
	HDC			m_MemDC;
	HBITMAP		m_MemBitmap;
	sTab*		m_pCurTab;
	COLORREF	m_cHighlightedTabColor;
	COLORREF	m_cTabColor;


	void	DrawTab(sTab* pTab,RECT rect);
	void	MeasureTab(sTab* pTab,RECT rect,int& x);

	sTab*		HitTest(POINT pos);
	
	void	ArrangeTab();

protected:
	LRESULT OnSize(WPARAM wParam,LPARAM lParam);
	LRESULT OnPaint(WPARAM wParam,LPARAM lParam);
	LRESULT OnLButtonDown(WPARAM wParam,LPARAM lParam);
	LRESULT OnEraseBkGnd(WPARAM wParam,LPARAM lParam);
	
};